package cn.lingyangwl.agile.common.security.config;

import cn.lingyangwl.framework.security.submit.RepeatSubmitDefinition;
import cn.lingyangwl.agile.common.core.exception.enums.GlobalErrorEnum;
import cn.lingyangwl.agile.common.security.utils.SecurityUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author shenguangyang
 */
@Configuration
public class RepeatSubmitConfig {

    @Bean
    public RepeatSubmitDefinition repeatSubmitDefinition() {
        return RepeatSubmitDefinition.builder()
                .baseError(GlobalErrorEnum.REPEAT_SUBMIT)
                .headerTokenKey("request-token")
                .userId(() -> String.valueOf(SecurityUtils.getUserId()))
                .build();
    }
}
